package xyc.szk.web.servlet.session;
/*
 * @Description:
 * @Author: 山志凯
 * @Date: 2021-04-21
 * @Time: 08:37
 */

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/success")
public class SuccessServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=ytf-8");
        //获取 登录验证时传过来信息，并显示登录成功的用户名称
        HttpSession session = req.getSession();//获取session对象
        String userName = (String) session.getAttribute("loginInfo");
        //获取登录成功的验证信息
        String msg = (String) req.getAttribute("msg");
        resp.getWriter().write("登录成功,"+userName+msg);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
